home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Magazine 28 Bonus / CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin / data / shared.dir / 03022_Script_BUTTON INDEX < prev    next >
Text File  |  1996-06-21  |  4KB  |  113 lines

  1. -- -----------------------------------------------------------
  2. -- Handler getVButtonIndexOffSet gets the index of the
  3. -- button in the given vertical button bar.
  4.  
  5. on getVButtonIndexOffSet S, numDivisions, V
  6.   global OneButtonHeight
  7.   set OffSetTop = 3
  8.   set ButtonBarHeight = the height of sprite S
  9.   set OneButtonHeight = ButtonBarHeight/numDivisions + OffSetTop
  10.   set ButtonBarTop = (the top of sprite S) 
  11.   
  12.   -- the resulting segment index is 1-based
  13.   return ((V - ButtonBarTop) / OneButtonHeight) + 1
  14. end
  15.  
  16. -- -----------------------------------------------------------
  17. -- -----------------------------------------------------------
  18. -- Handler getVButtonIndex gets the index of the
  19. -- button in the given vertical button bar.
  20.  
  21. on getVButtonIndex S, numDivisions, V
  22.   global OneButtonHeight
  23.   set ButtonBarHeight = the height of sprite S
  24.   set OneButtonHeight = ButtonBarHeight/numDivisions 
  25.   set ButtonBarTop = the top of sprite S
  26.   
  27.   -- the resulting segment index is 1-based
  28.   return ((V - ButtonBarTop) / OneButtonHeight) + 1
  29. end
  30.  
  31. -- ----------------------------------------------------------
  32. -- Handler getHButtonIndex gets the index of the
  33. -- button in the given horizontal button bar.
  34.  
  35. on getHButtonIndex S, numDivisions, H
  36.   set ButtonBarWidth = the width of sprite S
  37.   set OneButtonWidth = ButtonBarWidth / numDivisions
  38.   set ButtonBarLeft = the left of sprite S 
  39.   
  40.   -- the resulting segment index is 1-based
  41.   return ((H - ButtonBarLeft) / OneButtonWidth) + 1
  42. end
  43.  
  44. -- -----------------------------------------------------------
  45. -- Handler getVHButtonIndex gets the index of the
  46. -- button in the given 2 dimensional button bar (assuming that
  47. -- the numbers go down and then across).
  48.  
  49. on getVHButtonIndex buttonBar, numVItems, numHItems, V, H
  50.   set Hindex = getHButtonIndex(buttonBar,numHItems,H)
  51.   set Vindex = getVButtonIndex(buttonBar,numVItems,V)
  52.   
  53.   return ((Hindex-1) * numVItems) + Vindex
  54. end
  55.  
  56.  
  57. --Handler ButtonClick
  58.  
  59. on buttonClick destination
  60.   puppetSprite the clickOn, TRUE
  61.   set clickedCast = the clickon
  62.   if clickedCast < 1 then exit
  63.   
  64.   set CastNumber = the castNum of sprite clickedCast
  65.   set CastName = the name of cast CastNumber
  66.   set NumChars = the number of chars in CastName
  67.   
  68.   if the last char of CastName = "n" then
  69.     set NewName =  char 1 to (NumChars - 2) of CastName &  "out"
  70.   else
  71.     set NewName =  char 1 to (NumChars - 3) of CastName &  "in"
  72.   end if
  73.   set the castNum of sprite clickedCast = cast NewName
  74.   updateStage
  75.   goSection destination
  76.   puppetSprite clickedCast, FALSE
  77.   updateStage
  78. end
  79.  
  80. --Handler ButtonClickLife
  81.  
  82. on NextPageLife 
  83.   puppetSprite the clickOn, TRUE
  84.   set CastNumber = the castNum of sprite the clickOn
  85.   set CastName = the name of cast CastNumber
  86.   set NumChars = the number of chars in CastName
  87.   set ShortChars = NumChars - 2
  88.   set NewName =  char 1 to ShortChars of CastName &  "in"
  89.   set the castNum of sprite the clickOn = cast NewName
  90.   updateStage
  91.   --waitTicks 30
  92.   go to the frame + 1
  93.   puppetSprite the clickOn, FALSE
  94.   updateStage
  95.   --waitTicks 30
  96. end
  97.  
  98. on BackPageLife 
  99.   puppetSprite the clickOn, TRUE
  100.   set CastNumber = the castNum of sprite the clickOn
  101.   set CastName = the name of cast CastNumber
  102.   set NumChars = the number of chars in CastName
  103.   set ShortChars = NumChars - 2
  104.   set NewName =  char 1 to ShortChars of CastName &  "in"
  105.   set the castNum of sprite the clickOn = cast NewName
  106.   updateStage
  107.   --waitTicks 30
  108.   go to the frame - 1
  109.   puppetSprite the clickOn, FALSE
  110.   updateStage
  111.   --waitTicks 30
  112. end
  113.